﻿///Write a program that extracts from a given text all palindromes, e.g. "ABBA", "lamal", "exe".

using System;
using System.Globalization;
using System.Text.RegularExpressions;

class zad20
{
    static void Main()
    {
        string strIn =  @"Nice blue sky. No exe flying in the sky. ABBA will not come in Bulgaria.
I don`t know what is lamal, maybe I will find some day. mouseesuom";

        string[] arrayOfStrings = strIn.Split(new char[] { ' ', '.', ',', '!', '?' }, StringSplitOptions.RemoveEmptyEntries);
        
        for (int i = 0; i < arrayOfStrings.Length; i++)
        {
            string str = arrayOfStrings[i];
            bool isPalindrom = false;
            
            for (int j = 0; j < str.Length / 2; j++)
            {
                if (str.Substring(j, 1) == str.Substring(str.Length - 1 - j, 1))
                {
                    isPalindrom = true;
                }
                else
                {
                    isPalindrom = false;
                    break;
                }
            }

            if (isPalindrom == true && str.Length > 1)
            {
                Console.WriteLine(str);
            }

        }
    }
    
}

